home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / AfterDark / TwilightZone ƒ / source / base.window.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-18  |  4.1 KB  |  224 lines  |  [TEXT/KAHL]

  1. /*-------------------------------------------------------------------------------------
  2.  *
  3.  * Simple Sample Application Framework
  4.  *
  5.  * ©1991 Apple Computer
  6.  *
  7.  -------------------------------------------------------------------------------------*/
  8. /*
  9.  * windowstuff.c -- window class instantiation/dispatching
  10.  *
  11.  * change history:
  12.  *
  13.  * SJF        11/7/91        1.0d1        initial coding
  14.  *
  15.  */
  16.  
  17. #include "const.h"
  18. #include "strconst.h"
  19. #include "mytypes.h"
  20. #include "mymenus.h"
  21. #include "globals.h"
  22. #include "utils.h"
  23. #include "windowstuff.h"
  24.  
  25. #include "base.window.h"
  26.  
  27.  
  28. /* instantiate a new base window */
  29.  
  30. WindowPtr BaseMakeWindow(Rect *wRect,StringPtr title,Boolean visible,short wdefProc,Boolean goAwayFlag)
  31. {
  32.     TInfoHndl infoHndl;
  33.     TInfoPtr infoPtr;
  34.     WindowPtr theWindow;
  35.     Str255 defaultTitle;
  36.         
  37.     if (title==nil) {
  38.         pstrcpy(defaultTitle,kDefaultTitle);
  39.         title = defaultTitle;
  40.     }
  41.     
  42.     infoHndl = NewHandleChk(sizeof(TInfo));
  43.     if (MemError()!=noErr)
  44.         return nil;
  45.     
  46.     MoveHHi((Handle)infoHndl);
  47.     HLock((Handle)infoHndl);
  48.     infoPtr = *infoHndl;
  49.     
  50.     infoPtr->m_idle = BaseIdleWindow;
  51.     infoPtr->m_fixCursor = BaseFixCursorWindow;
  52.     infoPtr->m_activate = BaseActivateWindow;
  53.     infoPtr->m_deactivate = BaseDeactivateWindow;
  54.     infoPtr->m_update = BaseUpdateWindow;
  55.     infoPtr->m_key = BaseKeyWindow;
  56.     infoPtr->m_resize = BaseResizeWindow;
  57.     infoPtr->m_click = BaseClickWindow;
  58.     infoPtr->m_destroy = BaseDestroyWindow;
  59.     infoPtr->m_undo = BaseUndoWindow;
  60.     infoPtr->m_cut = BaseCutWindow;
  61.     infoPtr->m_copy = BaseCopyWindow;
  62.     infoPtr->m_paste = BasePasteWindow;
  63.     infoPtr->m_clear = BaseClearWindow;
  64.     infoPtr->m_print = BasePrintWindow;
  65.     infoPtr->m_pageSetup = BasePageSetupWindow;
  66.     infoPtr->m_save = BaseSaveWindow;
  67.     infoPtr->m_load = BaseLoadWindow;
  68.     infoPtr->m_event = BaseEventWindow;
  69.     
  70.     HUnlock((Handle)infoHndl);
  71.     
  72.     if (HasColorQD())
  73.         theWindow = NewCWindow(nil,wRect,title,visible,wdefProc,(WindowPtr)-1L,goAwayFlag,(unsigned long)infoHndl);
  74.  
  75.     else
  76.         theWindow = NewWindow(nil,wRect,title,visible,wdefProc,(WindowPtr)-1L,goAwayFlag,(unsigned long)infoHndl);
  77.         
  78.     ((WindowPeek)theWindow)->windowKind = kBaseWindow;
  79.     
  80.     infoPtr->window = theWindow;
  81.     infoPtr->saved = false;
  82.     infoPtr->changed = true;
  83.     
  84.     return theWindow;
  85. }
  86.  
  87.  
  88. void *BaseDestroyWindow(WindowPtr window,TInfoPtr info,void *data)
  89. {    
  90.     return nil;
  91. }
  92.  
  93.  
  94. void *BaseIdleWindow(WindowPtr window,TInfoPtr info,void *data)
  95. {
  96.     return nil;
  97. }
  98.  
  99.  
  100. void *BaseFixCursorWindow(WindowPtr window,TInfoPtr info,void *data)
  101. {
  102.     return;
  103. }
  104.  
  105.  
  106. void *BaseActivateWindow(WindowPtr window,TInfoPtr info,void *data)
  107. {
  108.     MenuHandle theMenu;
  109.     
  110.     theMenu = GetMHandle(kFileMenu);
  111.     EnableItem(theMenu,kCloseItem);
  112.     
  113.     SetCursor(&qd.arrow);
  114.     return nil;
  115. }
  116.  
  117.  
  118. void *BaseDeactivateWindow(WindowPtr window,TInfoPtr info,void *data)
  119. {
  120.     MenuHandle theMenu;
  121.  
  122.     theMenu = GetMHandle(kFileMenu);
  123.     DisableItem(theMenu,kCloseItem);
  124.  
  125.     SetDefaultMenus();
  126.     DrawMenuBar();
  127.     return nil;
  128. }
  129.  
  130.  
  131. void *BaseUpdateWindow(WindowPtr window,TInfoPtr info,void *data)
  132. {
  133.     return nil;
  134. }
  135.  
  136.  
  137. void *BaseResizeWindow(WindowPtr window,TInfoPtr info,void *data)
  138. {    
  139.     RgnHandle theRgn;
  140.     Rect *oldSize;
  141.     
  142.     return nil;
  143. }
  144.  
  145.  
  146. void *BaseKeyWindow(WindowPtr window,TInfoPtr info,void *data)
  147. {
  148.     return nil;
  149. }
  150.  
  151.  
  152. void *BaseClickWindow(WindowPtr window,TInfoPtr info,void *data)
  153. {
  154.     info->changed = true;
  155.     return nil;
  156. }
  157.  
  158.  
  159. void *BaseUndoWindow(WindowPtr window,TInfoPtr info,void *data)
  160. {
  161.     return nil;
  162. }
  163.  
  164.  
  165. void *BaseCutWindow(WindowPtr window,TInfoPtr info,void *data)
  166. {
  167.     return nil;
  168. }
  169.  
  170.  
  171. void *BaseCopyWindow(WindowPtr window,TInfoPtr info,void *data)
  172. {
  173.     return nil;
  174. }
  175.  
  176.  
  177. void *BasePasteWindow(WindowPtr window,TInfoPtr info,void *data)
  178. {
  179.     return nil;
  180. }
  181.  
  182.  
  183. void *BaseClearWindow(WindowPtr window,TInfoPtr info,void *data)
  184. {
  185.     return nil;
  186. }
  187.  
  188.  
  189. void *BasePrintWindow(WindowPtr window,TInfoPtr info,void *data)
  190. {
  191.     return nil;
  192. }
  193.  
  194.  
  195. void *BasePageSetupWindow(WindowPtr window,TInfoPtr info,void *data)
  196. {
  197.     return nil;
  198. }
  199.  
  200.  
  201. void *BaseSaveWindow(WindowPtr window,TInfoPtr info,void *data)
  202. {
  203.     info->saved = true;
  204.     info->changed = false;
  205.  
  206.     return nil;
  207. }
  208.  
  209.  
  210. void *BaseLoadWindow(WindowPtr window,TInfoPtr info,void *data)
  211. {
  212.     info->saved = true;
  213.     info->changed = false;
  214.  
  215.     return nil;
  216. }
  217.  
  218.  
  219. void *BaseEventWindow(WindowPtr window,TInfoPtr info,void *data)
  220. {
  221.     return nil;
  222. }
  223.  
  224.